package cn.renhui.hermesbus.core;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import cn.renhui.hermesbus.HarmesEventBusInterface;
import cn.renhui.hermesbus.Request;
import cn.renhui.hermesbus.Response;
import cn.renhui.hermesbus.response.InstanceResponseMake;
import cn.renhui.hermesbus.response.ObjectResponceMake;
import cn.renhui.hermesbus.response.ResponceMake;

public class HermesService extends Service {

    public HermesService() {

    }

    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }

    private HarmesEventBusInterface.Stub binder = new HarmesEventBusInterface.Stub() {
        @Override
        public Response send(Request request) throws RemoteException {
            ResponceMake responceMake = null;
            switch (request.getType()) {
                case Hermes.TYPE_NEW:
                    responceMake = new ObjectResponceMake();
                    break;
                case Hermes.TYPE_GET:
                    responceMake = new InstanceResponseMake();
                    break;
            }
            return responceMake.makeResponce(request);
        }
    };
}
